package com.todo.component.mq.conf;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author azhebuxing
 * @date 2024/12/11 02:22
 * @description
 */
@Configuration
public class StrategyRabbitConfig {

    public static final String EXCHANGE_STRATEGY = "todoAdmin-strategy";

    public static final String QUEUE_P_STRATEGY_STATUS = "pStrategyStatusChange";
    public static final String QUEUE_P_STRATEGY_STATUS_ROUTING_KEY = "pStrategyStatusChange";

    public static final String QUEUE_U_STRATEGY_STATUS = "uStrategyStatusChange";
    public static final String QUEUE_U_STRATEGY_STATUS_ROUTING_KEY = "uStrategyStatusChange";

    @Bean
    public DirectExchange strategyExchange() {
        return ExchangeBuilder.directExchange(EXCHANGE_STRATEGY).durable(true).build();
    }

    @Bean
    public Queue queuePStatusChange(){
        //内容状态流转
        return new Queue(QUEUE_P_STRATEGY_STATUS);
    }
    @Bean
    public Binding bindingPStatusChange() {
        return BindingBuilder.bind(queueUStatusChange()).to(strategyExchange()).with(QUEUE_P_STRATEGY_STATUS_ROUTING_KEY);
    }

    @Bean
    public Queue queueUStatusChange(){
        //内容状态流转
        return new Queue(QUEUE_U_STRATEGY_STATUS);
    }
    @Bean
    public Binding bindingUStatusChange() {
        return BindingBuilder.bind(queueUStatusChange()).to(strategyExchange()).with(QUEUE_U_STRATEGY_STATUS_ROUTING_KEY);
    }
}
